{#    登录模态框#}
<button type="button" style="display: none;" class="btn btn-primary open_loginUI" data-toggle="modal"
        data-target=".bs-example-modal-sm">Small modal
</button>

<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <button type="button" class="close index_close" data-dismiss="modal" aria-label="Close"><span
                    aria-hidden="true">&times;</span></button>
            <div class="loginpage">
                <div class="loginpage-content insert_loginUI">
                    <div class="loginpage-head">
                        <h2 style="color: #E14961">会员登录</h2>
                    </div>
                    <div class="loginpage-form">
                        <form action="#" id="my_Form_mt">
                            <input type="hidden" value="0" name="is_mt">
                            <div class="form-group">
                                <label for="username1">QQ邮箱</label>
                                <input type="text" form="my_Form_mt" oninput="clear_email_msg()"
                                       class="form-control must_input find_password" id="username1" name="email"
                                       placeholder="输入您的QQ邮箱">
                                <span id="email_msg" class="msg" style="color: #E14961">{{ email_msg }}</span>
                            </div>
                            <div class="form-group">
                                <label for="password1">密码</label>
                                <input type="password" form="my_Form_mt" class="form-control must_input" id="password1"
                                       name="password" placeholder="输入您的密码">
                            </div>
                            <div class="form-group">
                                <label for="changeCode1" style="display: block;">验证码</label>
                                <input type="text" id="changeCode1" oninput="clear_code_msg()" name="code"
                                       class="text captcha must_input" maxlength="4" autocomplete="off"><img
                                    id="captchaImage1"
                                    onclick="this.src='{{ url_for('validate_code.get_code') }}?'+ Math.random()"
                                    onclass="captchaImage" class="get_pic_code"
                                    src="{{ url_for('validate_code.get_code') }}" title="点击更换验证码">
                                <span id="code_msg" class="msg" style="color: #E14961">{{ code_msg }}</span>
                            </div>
                            <div class="login-button">
                                <button type="button" class="btn btn-block btn-primary" id="login"
                                        onclick="checkAll_motai()">登录
                                </button>
                            </div>
                        </form>
                    </div>
                    <div class="copy-right">
                        <p class="other_msg">
                            <a href="/user/register">注册会员</a>
                            <a class="reset_password" href="#">找回密码</a>
                        </p>
                        <p style="text-align: center">© 2020 南工二手交易平台</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    function checkAll_motai() {
        var i = 0;
        $(".must_input").each(function () {
            if ($(this).val().trim() == "") {
                $(this).focus()
                i++;
                return false
            }
        })
        if (i != 0) {
            return false;
        } else {
            $.post("/user/login", $('#my_Form_mt').serialize(), function (result) {
                console.log(result)
                if (result.status != 200) {
                    $('#captchaImage1').click()
                    $(result.error_pos).text(result.msg)
                } else {
                    location.reload()
                }
            });
        }
    }

    function clear_code_msg() {
        $('#code_msg').text('')
    }

    function clear_email_msg() {
        $("#email_msg").text('')
    }
</script>